#pragma once

#include <opencv2/opencv.hpp>
#include <unordered_map>
#include "BytekalmanFilter.h"

enum TrackState { New = 0, Tracked, Lost, Removed };

class STrack
{
public:
	STrack(const std::vector<float>& tlwh_, const float& score, const int& cls_id);
	~STrack();

	std::vector<float> static tlbr_to_tlwh(std::vector<float>& tlbr);
	void static multi_predict(std::vector<STrack*>& stracks, byte_kalman::ByteKalmanFilter& kalman_filter);
	void static_tlwh();
	void static_tlbr();
	std::vector<float> tlwh_to_xyah(std::vector<float> tlwh_tmp);
	std::vector<float> to_xyah();
	void mark_lost();
	void mark_removed();

	static void init_trackid_dict(const int n_classes);
	static int next_id(const int& cls_id);
	int end_frame();

	void activate(byte_kalman::ByteKalmanFilter& kalman_filter, int frame_id);
	void re_activate(STrack& new_track, int frame_id, bool new_id = false);
	void update(STrack& new_track, int frame_id);

public:
	bool is_activated;
	int track_id;
	int class_id;
	int state;

	std::vector<float> _tlwh;
	std::vector<float> tlwh;
	std::vector<float> tlbr;
	int frame_id;
	int tracklet_len;
	int start_frame;

	KAL_MEAN mean;
	KAL_COVA covariance;
	float score;

	// mapping each class id to the track id count of this class
	static std::unordered_map<int, int> static_track_id_dict;

private:
	byte_kalman::ByteKalmanFilter kalman_filter;
};